using System.Collections;
using System.Collections.Generic;
using OneDayModel.Interfaces;
using OneDayModel.Model;
using OneDayModel.PresentationLogic;
using OneDayModel.Tests.Mocks;

namespace OneDayModel.Tests.Fits.UIUsers
{
    public class StatisticsUser : IStatisiticsUI
    {
        private List<Statistic> totals;
        private List<Statistic> online;
        private List<Statistic> newToday;

        public StatisticsUser()
        {
            new StatisticsUILogic(this, StatisticsModel.GetInstance(new MockRepository()));
        }

        public string GetTotal()
        {
            return GetStatisticsAsString(totals);
        }

        private static string GetStatisticsAsString(IEnumerable<Statistic> statistics)
        {
            string result = string.Empty;
            string separator = string.Empty;
            foreach (Statistic statistic in statistics)
            {
                result += separator + statistic.Role + "=" + statistic.Value;
                separator = ";";
            }
            return result;
        }

        public string GetOnline()
        {
            return GetStatisticsAsString(online);
        }

        public string GetNewToday()
        {
            return GetStatisticsAsString(newToday);
        }

        public void SetTotals(IEnumerable<Statistic> totals)
        {
            this.totals = new List<Statistic>(totals);
        }

        public void SetOnline(IEnumerable<Statistic> online)
        {
            this.online = new List<Statistic>(online);
        }

        public void SetNewToday(IEnumerable<Statistic> newToday)
        {
            this.newToday = new List<Statistic>(newToday);
        }
    }

    
}